from flask_sqlalchemy import SQLAlchemy

db = SQLAlchemy()

class Student(db.Model):
    __tablename__ = "student"
    
    Sno = db.Column(db.String(20), primary_key=True, comment="学号")
    Sname = db.Column(db.String(20), nullable=False, comment="姓名")
    Ssex = db.Column(db.String(20), nullable=False, comment="性别")
    Sage = db.Column(db.Integer, nullable=False, comment="年龄")
    Dno = db.Column(db.String(20), nullable=False, comment="所属院系")
    Sclass = db.Column(db.String(20), comment="班级")
    address = db.Column(db.String(255), comment="家庭住址")

    def to_dict(self):
        return {
            'Sno': self.Sno,
            'Sname': self.Sname,
            'Ssex': self.Ssex,
            'Sage': self.Sage,
            'Dno': self.Dno,
            'Sclass': self.Sclass,
            'address': self.address
        } 